﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Project02
{
    class Car:Object
    {
        public float TimeInitial { get; set; }
        public float TimeFinal { get; set; }
        public float Timer { get; set; }

        public float VelocityInitial { get; set; }
        public float VelocityFinal { get; set; }

        public float Acceleration { get; set; }
        public float Kinematic { get; set; }

        public float DistanceInitial { get; set; }
        public float DistanceFinal { get; set; }

        private float travelledDistance;
        private float currentVelocity;

        public Car(Vector2 dimension, Vector2 location, int mass, GraphicsDevice graphicDevice)
            : base(dimension, location, mass, graphicDevice)
        {
            ObjTexture = CreateRectangle((int)dimension.X, (int)dimension.Y, Color.Navy);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(ObjTexture, Position + OffSet, null, Color.White, 0f, Origin, 1f, SpriteEffects.None, 0f);
            spriteBatch.Draw(AxisX, Position + OffSet, null, Color.White, 0f, new Vector2(Origin.X,1), 1f, SpriteEffects.None, 0f);
            spriteBatch.Draw(AxisY, Position + OffSet, null, Color.White, MathHelper.PiOver2, new Vector2(Origin.Y, 1), 1f, SpriteEffects.None, 0f);
        }

        public float CalculateTravelDistance()
        {
            travelledDistance = VelocityInitial * Timer + (Acceleration * Timer * TimeFinal) / 2;
            return travelledDistance;
        }

        public float CalculateCurrentVelocity()
        {
            currentVelocity = VelocityInitial + Acceleration * Timer;
            return currentVelocity;
        }
    }
}
